package com.jic.member.impl;

import com.jic.member.mapper.TripBranchNodeEntityMapper;
import com.jic.member.mapper.TripExecuteInfoEntityMapper;
import com.jic.member.entity.TripBranchNodeEntity;
import com.jic.member.entity.TripExecuteInfoEntity;
import com.jic.member.service.NodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yinhaijun
 * @date: 2020/6/5
 */
@Service("endNodeService")
public class EndNodeServiceImpl implements NodeService {
    @Autowired
    private TripBranchNodeEntityMapper tripBranchNodeEntityMapper;
    @Autowired
    private TripExecuteInfoEntityMapper tripExecuteInfoEntityMapper;
    @Override
    public void exe(Long tripId, Long nodeId, List<String> thirdUserIdList) {
        // 查询当前节点
        TripBranchNodeEntity b = tripBranchNodeEntityMapper.queryById(nodeId);
        for(String thirdUserId : thirdUserIdList){
            TripExecuteInfoEntity tripExecuteInfoEntity = new TripExecuteInfoEntity();
            tripExecuteInfoEntity.setThirdUserId(thirdUserId);
            tripExecuteInfoEntity.setBranchId(b.getBranchId());
            tripExecuteInfoEntity.setTripId(b.getTripId());
            tripExecuteInfoEntity.setBranchNodeId(b.getId());
            tripExecuteInfoEntity.setNodeTemplateCode(b.getNodeTemplateCode());
            tripExecuteInfoEntity.setRequestVariable(null);
            tripExecuteInfoEntity.setStatus(1);
            tripExecuteInfoEntity.setType(2);
            tripExecuteInfoEntityMapper.insert(tripExecuteInfoEntity);
        }
    }

}
